import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

// auto require all modules
const moduleFiles = require.context('./modules', true, /\.js$/)
const modules = moduleFiles.keys().reduce((module, path) => {
  module[path.replace(/^\.\/(.*)\.\w+$/, '$1')] = moduleFiles(path).default
  return module
}, {})

const store = new Vuex.Store({
  modules
})

export default store

